<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'修改密码', styles:'bootstrap,font-awesome,animate,style,dtvalidate,awesome-checkbox'}){%>
    <style type="text/css">
        body{padding-top:10px;}
    </style>
    <%}%>
</head>
<body>
<!-- START 内容部分 -->
<div class="container">
    <form class="form-horizontal" id="info-form" method="post">
        <div class="form-group">
            <label class="col-sm-2 control-label text-right">旧密码</label>
            <div class="col-sm-6">
                <input type="password" id="userOldPassword" name="oldpwd" class="form-control" valid="r|l5-l50" validTitle="旧密码" validInfoArea="userOldPassword_info_area" />
            </div>
            <div class="col-sm-4"><p class="help-block" id="userOldPassword_info_area"></p></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label text-right">新密码</label>
            <div class="col-sm-6">
                <input type="password" id="userPassword" name="newpwd" class="form-control" valid="r|l5-l50" validTitle="登录密码" validInfoArea="userPassword_info_area" />
            </div>
            <div class="col-sm-4"><p class="help-block" id="userPassword_info_area"></p></div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label text-right">新密码确认</label>
            <div class="col-sm-6">
                <input type="password" id="userRepeatPassword" name="userRepeatPassword" class="form-control" valid="r|l5-l50" validTitle="登录密码" validInfoArea="userRepeatPassword_info_area" validPassword="newpwd"/>
            </div>
            <div class="col-sm-4"><p class="help-block" id="userRepeatPassword_info_area"></p></div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="button" class="save-btn btn btn-primary">
                    <i class="fa fa-save"></i> 保存
                </button>
            </div>
        </div>
    </form>
</div>
<!-- END 内容部分 -->

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,dtvalidate,dtvalidate-lang-zh_cn'}){}%>
<script>
    var cvalidator;
    $(function(){
        //初始化验证器
        cvalidator = $.fn.dlshouwen.validator.init($('#info-form'));

        //提交表单
        $('.save-btn').on('click',function(){
            if(!cvalidator.validResult()){
                $.fn.dlshouwen.validator.tools.toast('验证失败！', 'error', 2000);
                return;
            }

            //数据提交
            $.post('${ctxPath}/power/user/changepwdsave.do',$('#info-form').serialize(),function(data){
                if( data.ok ){
                    parent.layer.msg(data.msg,{icon:1,time:2000,shade: [0.8, '#393D49']}, function(){
                        //TODO 提示重新登录
                        parent.layer.closeAll(); //关闭弹窗
                    });
                }else{
                    parent.layer.msg(data.msg,{icon: 0,time:1500,shade: [0.8, '#393D49']});
                }
            });
        });
    });
</script>
</body>
</html>